/*
 * @Author: worldzb 
 * @Date: 2019-01-08 09:29:27 
 * @Last Modified by: worldzb
 * @Last Modified time: 2019-01-14 15:13:04
 */

import Auth from '../models/Auth.class';

export default {
    state:{
        user:"",
        token:''
    },
    getters:{
        getUser(state){
            return state.user;
        },
        getToken(state){
            return state.token;
        }
    },
    mutations:{
        login(state,parms){
            let auth=Auth.getInstance();
            auth.login(parms.username,parms.password,()=>{
                //登录完成后 auth.user 会自动赋值
                state.user=auth.user;
                state.token=auth.token;
            });
        },

        logout(state,call){
            let auth=Auth.getInstance();
            auth.logout(()=>{call()});
        }
    },
}